export const openWindow = (href: string) => {
    const newWindow: any = window.open()
    newWindow.opener = null
    newWindow.location = href
    newWindow.target = '_blank'
}

export const copy = () => {
    if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
        (window.getSelection() as any).removeAllRanges(); //这段代码必须放在前面否则无效
        const dom: any = document.querySelector('.cur-result'); //要复制文字的节点
        const range = document.createRange();
        // 选中需要复制的节点
        range.selectNode(dom);
        // 执行选中元素
        (window.getSelection() as any).addRange(range);
        // 执行 copy 操作
        document.execCommand('copy');
        // 移除选中的元素
        (window.getSelection() as any).removeAllRanges();
    } else {
        const input = document.createElement('input');
        input.setAttribute('readonly', 'readonly');
        input.setAttribute('value', '');
        document.body.appendChild(input);
        input.setSelectionRange(0, 9999);
        input.select();
        document.execCommand('copy')
        document.body.removeChild(input);
    }
}